package zhtt;

import org.apache.ibatis.session.SqlSession;
import org.junit.Test;
import zhtt.demo01.Blog;
import zhtt.demo01.BlogMapper;

import java.util.HashMap;

/**
 * Created by zhtt on 2017/4/29.
 */
public class JunitTest {

    @Test
    public void get(){
        SqlSession session = SessionFactoryUtil_UNPOOLED.getSqlSessionIntance();
        try{
            BlogMapper mapper = session.getMapper(BlogMapper.class);
            Blog blog=mapper.selectBlog(1);
            System.out.println(blog);
            session.commit();
        }finally {
            session.close();
        }
    }

    @Test
    public void pooled(){
        SqlSession session = SessionFactoryUtil_POOLED.getSqlSessionIntance();
        try{
            BlogMapper mapper = session.getMapper(BlogMapper.class);
            Blog blog=mapper.selectBlog(1);
            System.out.println(blog);
            session.commit();
        }finally {
            session.close();
        }
    }

    @Test
    public void load(){
        SqlSession session = SessionFactoryUtil_UNPOOLED.getSqlSessionIntance();
        try{
            BlogMapper mapper = session.getMapper(BlogMapper.class);
            HashMap blog=mapper.load(1);
            System.out.println(blog);
            session.commit();
        }finally {
            session.close();
        }
    }
}
